package com.chinaunicom.tree;

import com.chinaunicom.tree.stack.StackMember;

public class TreeNode<T extends NodeData> implements StackMember {

	private T treeData;
	private TreeNode<T> parent;
	private TreeNode<T> leftChild;
	private TreeNode<T> rightChild;

	public TreeNode() { }
	
	public TreeNode(T treeData) {
		this(treeData, null, null, null);
	}

	public TreeNode(T treeData, TreeNode<T> parent, TreeNode<T> leftChild,
			TreeNode<T> rightChild) {
		super();
		this.treeData = treeData;
		this.parent = parent;
		this.leftChild = leftChild;
		this.rightChild = rightChild;
	}

	public T getTreeData() {
		return treeData;
	}

	public void setTreeData(T treeData) {
		this.treeData = treeData;
	}

	public TreeNode<T> getParent() {
		return parent;
	}

	public void setParent(TreeNode<T> parent) {
		this.parent = parent;
	}

	public TreeNode<T> getLeftChild() {
		return leftChild;
	}

	public void setLeftChild(TreeNode<T> leftChild) {
		this.leftChild = leftChild;
	}

	public TreeNode<T> getRightChild() {
		return rightChild;
	}

	public void setRightChild(TreeNode<T> rightChild) {
		this.rightChild = rightChild;
	}

	@Override
	public String toString() {
		return "treeData=" + treeData.toString();
	}
}
